extends ../layout1

block content
    div.container
        h2 欢迎注册!!! #{datas}
        form(role='form' action='/users/register' method='post')
            div.row
                div.col-sm-3
                    div.form-group
                        label(for='username') 用户名
                        input.form-control#username(type='text' name='username' placeholder='请输入用户名')
                    div.form-group
                        label(for='password') 密码
                        input.form-control#password(type='password' name='password' placeholder='请输入密码')
                    div.btn.btn-info#btn 注册

        div.panel.panel-info
            div.panel-heading 已注册会员
            div.panel-body
                table.table
                    tr
                        th  序号
                        th  用户名
                        th  密码
                        th  注册时间
                    each data in datas
                        tr
                            td  #{data.id}
                            if data.username == "ewe"
                                td 等于 wew
                            else
                                td #{data.username}

                            td  #{data.password}
                            td  #{data.addtime}
block current_js
    //嵌套 javascript 代码 写法
    script(type='text/javascript').
        $("#btn").click(function() {
            var username = $("#username").val(),password = $("#password").val();
            $.post("/users/register",{"username":username,"password":password},function (res) {
                if(res.error != 200){
                    alert(res.info);
                }else {
                    window.location.reload();
                }
            });
        });



